import java.util.Vector;

/**
 * a class represents a component
 * each component has
 * few successors, one predecessor
 * id, char, and health 
 */
public class Component 
{
	private boolean isProbed;
	private int id;
	private double health;
	private Vector<Component> successors;
	private Component predecessor;
	private char c;
	
	public Component(int id, int health)
	{
		this.isProbed = false;
		this.id = id;
		this.health = health;
		this.successors = new Vector<Component>();
		this.predecessor = null; 
	}
	
	public Component getPredecessor()
	{
		return this.predecessor;
	}
	
	public void addSuccessor(Component c)
	{
		successors.add(c);
		c.setPredecessor(this);
	}
	
	public void setPredecessor(Component pred)
	{
		this.predecessor = pred;
	}
	
	public void setIsMonitored(boolean flag)
	{
		this.isProbed = flag;
	}
	
	public int getId()
	{
		return id;
	}
	
	public Vector<Component> getSuccessors()
	{
		return successors;
	}
	
	public boolean isProbed()
	{
		return this.isProbed;
	}
	
	public double getHealth()
	{
		return health;
	}
	
	public void setHealth(double h)
	{
		health = h;
	}
	
	public String toString()
	{
		return "C" + (id+1);
	}
	
	public void setC(char ch)
	{
		this.c = ch;
	}
	public char getC()
	{
		return this.c;
	}
}
